<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
                                                                                                          <el-form-item label="用户id" prop="usrId">
                    <el-input
                        v-model="queryParams.usrId"
                        placeholder="请输入用户id"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="合约码" prop="contractCode">
                    <el-input
                        v-model="queryParams.contractCode"
                        placeholder="请输入合约码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户号，同custNo" prop="accountReference">
                    <el-input
                        v-model="queryParams.accountReference"
                        placeholder="请输入账户号，同custNo"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户名称" prop="accountName">
                    <el-input
                        v-model="queryParams.accountName"
                        placeholder="请输入账户名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="币种" prop="currencyCode">
                    <el-input
                        v-model="queryParams.currencyCode"
                        placeholder="请输入币种"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户邮箱" prop="customerEmail">
                    <el-input
                        v-model="queryParams.customerEmail"
                        placeholder="请输入客户邮箱"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户姓名" prop="customerName">
                    <el-input
                        v-model="queryParams.customerName"
                        placeholder="请输入客户姓名"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户银行编码" prop="accountsBankCode">
                    <el-input
                        v-model="queryParams.accountsBankCode"
                        placeholder="请输入账户银行编码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户银行名称" prop="accountsBankName">
                    <el-input
                        v-model="queryParams.accountsBankName"
                        placeholder="请输入账户银行名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户编号" prop="accountsAccountNumber">
                    <el-input
                        v-model="queryParams.accountsAccountNumber"
                        placeholder="请输入账户编号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="账户名称" prop="accountsAccountName">
                    <el-input
                        v-model="queryParams.accountsAccountName"
                        placeholder="请输入账户名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="collectionChannel" prop="collectionChannel">
                    <el-input
                        v-model="queryParams.collectionChannel"
                        placeholder="请输入collectionChannel"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="reservationReference" prop="reservationReference">
                    <el-input
                        v-model="queryParams.reservationReference"
                        placeholder="请输入reservationReference"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="reservedAccountType" prop="reservedAccountType">
                    <el-select v-model="queryParams.reservedAccountType" placeholder="请选择reservedAccountType" clearable size="small">
                      <el-option label="请选择字典生成" value="" />
                    </el-select>
                  </el-form-item>
                                                                                                                  <el-form-item label="状态" prop="status">
                    <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
                      <el-option label="请选择字典生成" value="" />
                    </el-select>
                  </el-form-item>
                                                                                                                  <el-form-item label="创建时间" prop="createdOn">
                    <el-input
                        v-model="queryParams.createdOn"
                        placeholder="请输入创建时间"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="bvn" prop="bvn">
                    <el-input
                        v-model="queryParams.bvn"
                        placeholder="请输入bvn"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="restrictPaymentSource" prop="restrictPaymentSource">
                    <el-input
                        v-model="queryParams.restrictPaymentSource"
                        placeholder="请输入restrictPaymentSource"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="状态" prop="state">
                    <el-input
                        v-model="queryParams.state"
                        placeholder="请输入状态"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                                              <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['bizsys:ext_monnify_reserved_accounts:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['bizsys:ext_monnify_reserved_accounts:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['bizsys:ext_monnify_reserved_accounts:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['bizsys:ext_monnify_reserved_accounts:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ext_monnify_reserved_accountsList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
                                                          <el-table-column label="id" align="center" prop="id" />
                                                                      <el-table-column label="用户id" align="center" prop="usrId" />
                                                                      <el-table-column label="合约码" align="center" prop="contractCode" />
                                                                      <el-table-column label="账户号，同custNo" align="center" prop="accountReference" />
                                                                      <el-table-column label="账户名称" align="center" prop="accountName" />
                                                                      <el-table-column label="币种" align="center" prop="currencyCode" />
                                                                      <el-table-column label="客户邮箱" align="center" prop="customerEmail" />
                                                                      <el-table-column label="客户姓名" align="center" prop="customerName" />
                                                                      <el-table-column label="账户银行编码" align="center" prop="accountsBankCode" />
                                                                      <el-table-column label="账户银行名称" align="center" prop="accountsBankName" />
                                                                      <el-table-column label="账户编号" align="center" prop="accountsAccountNumber" />
                                                                      <el-table-column label="账户名称" align="center" prop="accountsAccountName" />
                                                                      <el-table-column label="collectionChannel" align="center" prop="collectionChannel" />
                                                                      <el-table-column label="reservationReference" align="center" prop="reservationReference" />
                                                                      <el-table-column label="reservedAccountType" align="center" prop="reservedAccountType" />
                                                                      <el-table-column label="状态" align="center" prop="status" />
                                                                      <el-table-column label="创建时间" align="center" prop="createdOn" />
                                                                      <el-table-column label="bvn" align="center" prop="bvn" />
                                                                      <el-table-column label="restrictPaymentSource" align="center" prop="restrictPaymentSource" />
                                                                      <el-table-column label="状态" align="center" prop="state" />
                                                                      <el-table-column label="备注" align="center" prop="remark" />
                                                                                                                                                                                                          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_reserved_accounts:edit']"
          >修改</el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_reserved_accounts:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改monnify虚拟账户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                                                                                                                                                            <el-form-item label="用户id" prop="usrId">
                          <el-input v-model="form.usrId" placeholder="请输入用户id" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="合约码" prop="contractCode">
                          <el-input v-model="form.contractCode" placeholder="请输入合约码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户号，同custNo" prop="accountReference">
                          <el-input v-model="form.accountReference" placeholder="请输入账户号，同custNo" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户名称" prop="accountName">
                          <el-input v-model="form.accountName" placeholder="请输入账户名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="币种" prop="currencyCode">
                          <el-input v-model="form.currencyCode" placeholder="请输入币种" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户邮箱" prop="customerEmail">
                          <el-input v-model="form.customerEmail" placeholder="请输入客户邮箱" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户姓名" prop="customerName">
                          <el-input v-model="form.customerName" placeholder="请输入客户姓名" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户银行编码" prop="accountsBankCode">
                          <el-input v-model="form.accountsBankCode" placeholder="请输入账户银行编码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户银行名称" prop="accountsBankName">
                          <el-input v-model="form.accountsBankName" placeholder="请输入账户银行名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户编号" prop="accountsAccountNumber">
                          <el-input v-model="form.accountsAccountNumber" placeholder="请输入账户编号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="账户名称" prop="accountsAccountName">
                          <el-input v-model="form.accountsAccountName" placeholder="请输入账户名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="collectionChannel" prop="collectionChannel">
                          <el-input v-model="form.collectionChannel" placeholder="请输入collectionChannel" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="reservationReference" prop="reservationReference">
                          <el-input v-model="form.reservationReference" placeholder="请输入reservationReference" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="reservedAccountType" prop="reservedAccountType">
                          <el-select v-model="form.reservedAccountType" placeholder="请选择reservedAccountType">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="状态">
                          <el-radio-group v-model="form.status">
                            <el-radio label="1">请选择字典生成</el-radio>
                          </el-radio-group>
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="创建时间" prop="createdOn">
                          <el-input v-model="form.createdOn" placeholder="请输入创建时间" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="bvn" prop="bvn">
                          <el-input v-model="form.bvn" placeholder="请输入bvn" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="restrictPaymentSource" prop="restrictPaymentSource">
                          <el-input v-model="form.restrictPaymentSource" placeholder="请输入restrictPaymentSource" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="状态" prop="state">
                          <el-input v-model="form.state" placeholder="请输入状态" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="备注" prop="remark">
                          <el-input v-model="form.remark" placeholder="请输入备注" />
                        </el-form-item>
                                                                                                                                                                                                                                                                                                                </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listExt_monnify_reserved_accounts, getExt_monnify_reserved_accounts, delExt_monnify_reserved_accounts, addExt_monnify_reserved_accounts, updateExt_monnify_reserved_accounts, exportExt_monnify_reserved_accounts } from "@/api/bizsys/ext_monnify_reserved_accounts";

  export default {
    name: "Ext_monnify_reserved_accounts",
    components: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
                  // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // monnify虚拟账户表格数据
              ext_monnify_reserved_accountsList: [],
                  // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
                                                                                usrId: null,
                                                                    contractCode: null,
                                                                    accountReference: null,
                                                                    accountName: null,
                                                                    currencyCode: null,
                                                                    customerEmail: null,
                                                                    customerName: null,
                                                                    accountsBankCode: null,
                                                                    accountsBankName: null,
                                                                    accountsAccountNumber: null,
                                                                    accountsAccountName: null,
                                                                    collectionChannel: null,
                                                                    reservationReference: null,
                                                                    reservedAccountType: null,
                                                                    status: null,
                                                                    createdOn: null,
                                                                    bvn: null,
                                                                    restrictPaymentSource: null,
                                                                    state: null,
                                                                                                                                                                                },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    createTime: [
                    { required: true, message: "创建时间不能为空", trigger: "blur" }
                  ],
                                                                                                                                        updateTime: [
                    { required: true, message: "更新时间不能为空", trigger: "blur" }
                  ]
                                    }
      };
    },
    created() {
      // this.getList();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                },
    methods: {
      /** 查询monnify虚拟账户列表 */
      getList() {
        this.loading = true;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            listExt_monnify_reserved_accounts(this.queryParams).then(response => {
          this.ext_monnify_reserved_accountsList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
                                                    id: null,
                                                                    usrId: null,
                                                                    contractCode: null,
                                                                    accountReference: null,
                                                                    accountName: null,
                                                                    currencyCode: null,
                                                                    customerEmail: null,
                                                                    customerName: null,
                                                                    accountsBankCode: null,
                                                                    accountsBankName: null,
                                                                    accountsAccountNumber: null,
                                                                    accountsAccountName: null,
                                                                    collectionChannel: null,
                                                                    reservationReference: null,
                                                                    reservedAccountType: null,
                                                                status: "0",
                                                                    createdOn: null,
                                                                    bvn: null,
                                                                    restrictPaymentSource: null,
                                                                    state: null,
                                                                    remark: null,
                                                                    createBy: null,
                                                                    createTime: null,
                                                                    updateBy: null,
                                                                    updateTime: null
                                    };
                  this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加monnify虚拟账户";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getExt_monnify_reserved_accounts(id).then(response => {
          this.form = response.data;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              this.open = true;
          this.title = "修改monnify虚拟账户";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (this.form.id != null) {
              updateExt_monnify_reserved_accounts(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addExt_monnify_reserved_accounts(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除monnify虚拟账户编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delExt_monnify_reserved_accounts(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
      },
              /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有monnify虚拟账户数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportExt_monnify_reserved_accounts(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
      }
    }
  };
</script>
